<?php

include 'SOAP/Client.php';

function dada_soap_subscribe($opt) {

	$email     = $opt['email']; // 'user@example.com';
	$list      = $opt['list']; // listshortname';
	$fields     = $opt['fields'] ? $opt['fields'] : array();
	$url = $opt['url'] ? $opt['url'] : 'http://disdroid.co.uk/cgi-bin/dada/extras/scripts/subscribe/subscribe_soap_server.cgi';
	// $namespace = $opt['namespace'] ? $opt['namespace'] : 'DadaMail';
	$namespace = 'DadaMail';

	$options = array('namespace' => $namespace, 'trace' => 1);

	$client = new SOAP_Client($url);

	$params = array($list, $email, $fields);

	$result = array();
	$result = $client->call("subscribe", $params, $options);

// 	echo "Subscription Check: $result[0]\n";
	
// 	$errors = $result[1];
	
// 	if($errors){
// 		echo "Errors: \n";
// 		while (list($key, $value) = each($errors)) {
// 			echo "	* Error: $key\n";
// 		}
// 	}
	
	return $result;
}